package com.example.qihuibao.widget.view

import android.app.Activity
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.example.qihuibao.R
import org.w3c.dom.Text

class TitleBar(ctx: Context, attr: AttributeSet) : LinearLayout(ctx, attr) {
    private lateinit var tvTitle:TextView
    private lateinit var ivBack:ImageView

    init {
        val root = LayoutInflater.from(ctx).inflate(R.layout.title_bar, this, true)
        tvTitle = root.findViewById<TextView>(R.id.tv_title)
        ivBack = root.findViewById<ImageView>(R.id.iv_back)
        ivBack.setOnClickListener { (ctx as Activity).finish() }
    }

    fun setTitle(title:String) {
        tvTitle.text = title
    }
}